<?php

class Application_Model_MessagesTbl extends Zend_Db_Table_Abstract{
	protected $_name = 'messages';
	
  	function readMessage($mailID)
    {
       $select = $this	->_db->select()
						->from($this->_name)
						->where('id=?',$mailID);

    	$result = $this->getAdapter()->fetchRow($select);
    	return $result;
    }
    
//    function getMessages($alias)
//    {
//    	$select = $this	->_db->select()
//						->from($this->_name)
//						->where('toAlias = ?',$alias);
//    	
//		$result = $this->getAdapter()->fetchAll($select);
//        return $result;
//    }
//    
// 	function getSentMessages($alias)
//    {
//    	$select = $this	->_db->select()
//						->from($this->_name)
//						->where('fromAlias =?',$alias);
//    	
//		$result = $this->getAdapter()->fetchAll($select);
//        return $result;
//    }
    
		
	function getInboxList($alias)
    {
    	$seletInboxMessages = new Zend_Db_Select($this->_db);
    	$seletInboxMessages->from($this->_name)
						->where('toAlias = ?',$alias)
    					->order('date DESC');
    	return $seletInboxMessages;
 	}
 	
	function getSentList($alias)
    {
    	$seletInboxMessages = new Zend_Db_Select($this->_db);
    	$seletInboxMessages->from($this->_name)
						->where('fromAlias =?',$alias)
    					->order('date DESC');
    	return $seletInboxMessages;
 	}
}
